From: Debian Science Maintainers Date: Sat, 2 Mar 2019 14:59:35 +0000 (+0000) Subject: Fix errors in examples X-Git-Tag: archive/raspbian/0.11.1-2+rpi1~2^2^2~3 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=9da7a037d47f144a5e40e3fe754d776d6659f156;p=statsmodels.git Fix errors in examples Be compatible with current pandas https://github.com/statsmodels/statsmodels/commit/66a4f98d0ac86ea957fa6f8168cc2df178c64630 https://github.com/statsmodels/statsmodels/commit/67415ad8d4c04dc1dd9ea9ebb1e059af92646c7b https://github.com/statsmodels/statsmodels/commit/572d507dfa28044166cf4f183177a046f90934ae and with one dataset layout change within statsmodels, based on https://github.com/statsmodels/statsmodels/commit/31ec838d1eab2ec559ab69d42151085bdf9f18e1 Look in the correct path for star_diagram.png (using this fix instead of https://github.com/statsmodels/statsmodels/commit/3363ce1dc41b1717db5b6779a2a9cbf8f72a0294 to be minimally risky during freeze) Author: Kevin "bashtage" Sheppard, Rebecca N. Palmer Origin: upstream (mostly) Forwarded: not-needed Gbp-Pq: Name examples_fixes.patch --- diff --git a/docs/source/contingency_tables.rst b/docs/source/contingency_tables.rst index e66c215..985bd99 100644 --- a/docs/source/contingency_tables.rst +++ b/docs/source/contingency_tables.rst @@ -265,7 +265,7 @@ methods and attributes. data = sm.datasets.china_smoking.load() mat = np.asarray(data.data) - tables = [np.reshape(x, (2, 2)) for x in mat] + tables = [np.reshape(list(x)[1:], (2, 2)) for x in mat] st = sm.stats.StratifiedTable(tables) print(st.summary()) diff --git a/examples/notebooks/discrete_choice_example.ipynb b/examples/notebooks/discrete_choice_example.ipynb index 9f9c483..3b7fda0 100644 --- a/examples/notebooks/discrete_choice_example.ipynb +++ b/examples/notebooks/discrete_choice_example.ipynb @@ -204,7 +204,7 @@ }, "outputs": [], "source": [ - "affair_mod.predict(respondent1000)" + "affair_mod.predict(pd.DataFrame(respondent1000).T) # patsy requires a DataFrame, not a Series" ] }, { @@ -521,8 +521,8 @@ }, "outputs": [], "source": [ - "resp25 = glm_mod.predict(means25)\n", - "resp75 = glm_mod.predict(means75)\n", + "resp25 = glm_mod.predict(pd.DataFrame(means25).T) # patsy requires a DataFrame, not a Series\n", + "resp75 = glm_mod.predict(pd.DataFrame(means75).T)\n", "diff = resp75 - resp25" ] }, diff --git a/examples/notebooks/pca_fertility_factors.ipynb b/examples/notebooks/pca_fertility_factors.ipynb index 58a1a71..7be3e37 100644 --- a/examples/notebooks/pca_fertility_factors.ipynb +++ b/examples/notebooks/pca_fertility_factors.ipynb @@ -273,7 +273,7 @@ "outputs": [], "source": [ "fig, ax = plt.subplots()\n", - "pd.tools.plotting.scatter_plot(pca_model.loadings, 'comp_00', 'comp_01', ax=ax)\n", + "pca_model.loadings.plot.scatter(x='comp_00', y='comp_01', ax=ax)\n", "ax.set_xlabel(\"PC 1\", size=17)\n", "ax.set_ylabel(\"PC 2\", size=17)\n", "dta.index[pca_model.loadings.ix[:, 1] > .2].values" diff --git a/examples/notebooks/robust_models_1.ipynb b/examples/notebooks/robust_models_1.ipynb index 6945973..8f90ee4 100644 --- a/examples/notebooks/robust_models_1.ipynb +++ b/examples/notebooks/robust_models_1.ipynb @@ -675,7 +675,7 @@ "outputs": [], "source": [ "sidak = ols_model.outlier_test('sidak')\n", - "sidak.sort('unadj_p', inplace=True)\n", + "sidak.sort_values('unadj_p', inplace=True)\n", "print(sidak)" ] }, @@ -688,7 +688,7 @@ "outputs": [], "source": [ "fdr = ols_model.outlier_test('fdr_bh')\n", - "fdr.sort('unadj_p', inplace=True)\n", + "fdr.sort_values('unadj_p', inplace=True)\n", "print(fdr)" ] }, @@ -776,7 +776,8 @@ "outputs": [], "source": [ "from IPython.display import Image\n", - "Image(filename='star_diagram.png')" + "import os.path\n", + "Image(filename='star_diagram.png' if os.path.exists('star_diagram.png') else '../examples/notebooks/star_diagram.png')" ] }, { @@ -845,7 +846,7 @@ "outputs": [], "source": [ "sidak2 = ols_model.outlier_test('sidak')\n", - "sidak2.sort('unadj_p', inplace=True)\n", + "sidak2.sort_values('unadj_p', inplace=True)\n", "print(sidak2)" ] }, @@ -858,7 +859,7 @@ "outputs": [], "source": [ "fdr2 = ols_model.outlier_test('fdr_bh')\n", - "fdr2.sort('unadj_p', inplace=True)\n", + "fdr2.sort_values('unadj_p', inplace=True)\n", "print(fdr2)" ] },